import 'package:flutter/material.dart';
import 'package:flutter_trip/models/common_model.dart';
import 'package:flutter_trip/models/grid_nav_model.dart';
import 'package:flutter_trip/widget/webview.dart';

class LocalNav extends StatelessWidget{
  final List<CommonModel> localNavList;
  final String name;

  LocalNav(this.localNavList,{this.name='xiaoming'});

  @override
  Widget build(BuildContext context) {
     return Container(
       height: 64,
       decoration: BoxDecoration(
           color: Colors.white,
         borderRadius:  BorderRadius.all(Radius.circular(6)),

       ),
       child: Padding(
         padding: EdgeInsets.all(7),
         child: _items(context),
       ),
     );
  }
  
  _items(BuildContext context){
    if(localNavList == null) return null;
    List<Widget>items =[];
//    for(CommonModel m in localNavList){
//      print(m);
//      items.add(_item(context, m));
//    }
    localNavList.forEach((element) {
      items.add(_item(context, element));

    });
//    localNavList.map((e){
//      print(e);
//      items.add(_item(context, e));
//    });
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: items,
    );

  }
  Widget _item(BuildContext context,CommonModel model){
      return GestureDetector(
        onTap: (){
          Navigator.push(context, MaterialPageRoute(builder: (context)=>MyWebView(model.url, model.statusBarColor, model.title, model.hideAppBar)));
        },
        child: Column(children: [
          Image.network(model.icon,height: 32,width: 32,),
          Text(model.title,style: TextStyle(fontSize: 12),),

        ],),
      );
  }
}